package com.zhaojw.zr.web.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.zhaojw.zr.web.service.LoginService;

public class LoginAction extends ActionSupport {
	private static final long serialVersionUID = 1L;

	private String userName;
	private String password;
	@Autowired
	private LoginService loginService;
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		loginService.login();
		if(getUserName().equals("zhaojw")&&getPassword().equals("123456")){
			ActionContext.getContext().getSession().put("user", getUserName());
			return SUCCESS;
		}
		return ERROR;
	}
	
	

}
